package com.liu.netty.controller;

import com.liu.netty.entity.Driver;
import com.liu.netty.service.DriverService;
import entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import status.CodeEnum;

@RequestMapping("/driver")
@RestController
@Api(value="设备操作controller",tags={"设备接口"})
public class DriverController {

    @Autowired
    private DriverService driverService;


    @PostMapping
    @ApiOperation(value="添加设备", notes="添加设备",httpMethod = "POST")
    public Result add(@ApiParam(name="driver",value="传入json格式",required = true)@RequestBody Driver driver){

        driverService.addDriver(driver);

      return  new Result(true, CodeEnum.OK.getCode(),"设备添加成功");
    }

    @GetMapping("/{id}")
    public Result findDriverById(@PathVariable String id){
        Driver driver =driverService.selectById(id);
        System.out.println(driver);

        return new Result(true,CodeEnum.OK.getCode(),"查询成功！！",driver);
    }


}
